package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.RcglEducationLearningCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglEducationLearningResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.RcglEducationLearningUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.RcglEducationLearningEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface RcglEducationLearningConvert {

    RcglEducationLearningConvert INSTANCE = Mappers.getMapper(RcglEducationLearningConvert.class);

    RcglEducationLearningEntity createTo(RcglEducationLearningCreateDTO s);

    RcglEducationLearningEntity update(RcglEducationLearningUpdateDTO s);

    RcglEducationLearningResultDTO convert(RcglEducationLearningEntity s);

    default RcglEducationLearningEntity create(RcglEducationLearningCreateDTO s, Long tenantId) {
        RcglEducationLearningEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        return entity;
    }
}
